<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <!--      <el-form-item label="订单号" prop="orderId">-->
      <!--        <el-input v-model="queryParams.orderId" placeholder="请输入订单号" clearable/>-->
      <!--      </el-form-item>-->
      <el-form-item label="商品编码" prop="skuCode">
        <el-input v-model="queryParams.skuCode" placeholder="请输入商品编码" clearable/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="orderInfoStatisticsList" border stripe center>
      <el-table-column label="订单号" prop="orderId" align="center"></el-table-column>
      <el-table-column label="子订单号" prop="childOrderId" align="center"></el-table-column>
      <el-table-column label="商品编码" prop="skuCode" align="center"></el-table-column>
      <!--      <el-table-column label="订单号" prop="orderId" align="center"></el-table-column>-->
      <!--      <el-table-column label="子订单号" prop="childOrderId" align="center"></el-table-column>-->
      <el-table-column label="商品价格" prop="productTotalPrice" align="center" width="100"></el-table-column>
      <el-table-column label="真实采购价格" prop="realityPurchasePrice" align="center" width="100"></el-table-column>
      <el-table-column label="物流价格" prop="logisticsTotalPrice" align="center" width="100"></el-table-column>
      <el-table-column label="真实物流价格" prop="realLogisticsPrice" align="center" width="100"></el-table-column>
      <el-table-column label="商品数量" prop="productCount" align="center" width="100"></el-table-column>
      <el-table-column label="采购成本" prop="costTotalPrice" align="center" width="100"></el-table-column>
      <el-table-column label="子订单付款金额" prop="childAmount" align="center" width="100"></el-table-column>
      <el-table-column label="子订单利润" prop="productProfit" align="center" width="100"></el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {listOrderInfoStatistics} from "@/api/statistics/statistics";

export default {
  name: "OrderInfoStatistics",
  dicts: ['county_code'],
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 订单信息统计表格数据
      orderInfoStatisticsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderId: undefined,
        skuCode: undefined,
        country: undefined,
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询订单信息统计列表 */
    getList() {
      this.loading = true;
      listOrderInfoStatistics(this.queryParams).then(response => {
        this.orderInfoStatisticsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/orderInfoStatistics/export', {
        ...this.queryParams
      }, `orderInfoStatistics_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
